/*
 * Copyright (c) 2018. J4dream created
 */

package com.j4dream.property.javabasic.thread;

import static sun.nio.cs.Surrogate.MAX;

public class YieldThread extends Thread {
    public YieldThread(String name) {
        super(name);
    }

    public synchronized void run() {
        for (int i = 0; i < 6; i++) {
            System.out.printf("%s ,优先级为 : %d ----> %d\n", this.getName(), this.getPriority(), i);

            if (i == 2) {
                Thread.yield();
            }
        }
    }

    public static void main(String[] args) {
        YieldThread t1 = new YieldThread("1-thread");
        YieldThread t2 = new YieldThread("2-thread");
        //t2.setPriority(Thread.MAX_PRIORITY);
        t1.start();
        t2.start();
    }
}
